import random
import cvutil
h, s, l = 0, 0.9, 0.5


# 生成渐变色
def gen_gradient_color():
    global h, s, l
    h += 0.01
    if h >= 1:
        h = 0
    b, g, r = cvutil.hsl2bgr(h, s, l)
    return b, g, r, 255


# 生成随机色
def gen_random_color():
    return random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), 255


# 轴线数量
axisNum = 32

# 画布大小
paintGroundSize = (800, 800)

# 轴线中心点偏移
axisCenterOffset = 50

# 背景颜色(B, G, R, A)
bgColor = (255, 255, 255, 255)

# 对称轴颜色(B, G, R, A)
axisColor = (125, 125, 125, 255)

# 轴线宽度
axisThickness = 1

# 画笔颜色(B, G, R, A)或画笔生成方法
# paintColor = (248, 231, 28, 255)
paintColor = gen_gradient_color

# 画笔宽度
paintThickness = 1

# 显示轴线
displayAxis = True

# 保存图片路径
saved_file_name = 'result.png'

# PNG 压缩等级(0-9)
compress_level = 9


def _f(): pass


if __name__ == '__main__':
    def bgra2hex(color):
        return hex(
            ((color[2] & 0xffffffff) << 24) +
            ((color[1] & 0xffffffff) << 16) +
            ((color[0] & 0xffffffff) << 8) +
            (color[3] & 0xffffffff)
        )
    p = None
    if isinstance(paintColor, type(_f)) or isinstance(paintColor, type(lambda: None)):
        if paintColor.__name__ == 'gen_gradient_color':
            p = '渐变色画笔'
        elif paintColor.__name__ == 'gen_random_color':
            p = '随机色画笔'
        else:
            p = '自定义色彩生成方法'
    elif isinstance(paintColor, tuple):
        p = f'RGBA=({paintColor[2]}, {paintColor[1]}, {paintColor[0]}, {paintColor[3]}), HEX={bgra2hex(paintColor)}'
    print(f'''
对称轴数量 = \t\t\t{axisNum}
画布大小 = \t\t\t{paintGroundSize[0]} x {paintGroundSize[1]}
对称轴中心点偏移 = \t{axisCenterOffset} px
背景颜色 = \t\t\tRGBA=({bgColor[2]}, {bgColor[1]}, {bgColor[0]}, {bgColor[3]}), HEX={bgra2hex(bgColor)}
对称轴颜色 = \t\t\tRGBA=({axisColor[2]}, {axisColor[1]}, {axisColor[0]}, {axisColor[3]}), HEX={bgra2hex(axisColor)}
对称轴宽度 = \t\t\t{axisThickness}
画笔颜色 = \t\t\t{p}
画笔宽度 = \t\t\t{paintThickness}
显示轴线 = \t\t\t{displayAxis}
文件保存路径 = \t\t{saved_file_name}
png压缩等级 = \t\t{compress_level}''')
